<?php

$query_time = date("Y-m-d",time());
$qishu_query = "";
if($_GET['s_time']){
    $query_time = $_GET['s_time'];
	if(!regExp::checkTime($query_time))exit;
}
if($_GET['qishu_query']){
    $qishu_query = $_GET['qishu_query'];
	if(!regExp::isNumber($qishu_query,1,50))exit;
}
$lottery_type = $_GET['gtype'];
if($lottery_type=="D3" || $lottery_type=="D32"){
    $gType = "d3";
}elseif($lottery_type=="P3" || $lottery_type=="P32"){
    $gType = "p3";
}elseif($lottery_type=="T3" || $lottery_type=="T32"){
    $gType = "t3";
}
?>
<link rel="stylesheet" href="/resource/images/css/admin_style_1.css" type="text/css" media="all" />
<script language="javascript" src="/resource/js/jquery-1.7.2.min.js"></script>
<script language="javascript">
    function queryLottery(){
//        var timeParam = $("#s_time").val();
//        if(!timeParam){
//            alert("请选择日期。");
//            return false;
//        }
        return true;
    }
</script>
<style>
	#gtype{
			width: 25%;
			height: 35px;
			border: none;
			color: black;
			position:relative;
			left:2%;
			font-weight:bold;
	}
	#gtype:focus{
		border:none;
	}
	#search_content{
		height:130px;
		overflow:auto;
		
	}
	body{ border:none !important; background:none !important; }
	html{ width:95%; margin:auto; }
	img{ width:100% !important;}
</style>
<div id="search_content">
<div class="round-table">
    <form name="Frm_search_drawno"  id="Frm_search_drawno" method="get" onSubmit="return queryLottery();" action="./">
        <table width="100%" height="100%" border="0" cellpadding="5" cellspacing="1" class="font12">
            <tr style="background-color:#FFFFFF;">
                <td align="left">
                    <select name="gtype" id="gtype">
                     <option value="LT"    <?=$_GET['gtype']=='LT' ? 'selected' : ''?>>六合彩</option> 
                        <!-- <option value="LT"    <?=$_GET['gtype']=='LT' ? 'selected' : ''?>>六合彩</option> -->
                       <option value="D32"    <?=$_GET['gtype']=='D3' || $_GET['gtype']=='D32' ? 'selected' : ''?>>3D彩</option>
                        <option value="P32"    <?=$_GET['gtype']=='P3' || $_GET['gtype']=='P32' ? 'selected' : ''?>>排列三</option>
                     <option value="T32"    <?=$_GET['gtype']=='T3' || $_GET['gtype']=='T32' ? 'selected' : ''?>>上海时时乐</option>
                        <option value="CQM"    <?= $_GET['gtype']=='CQM' || $_GET['gtype']=='CQ'  ? 'selected' : ''?>>重庆时时彩</option>
                    <!--      <option value="JX"    <?=$_GET['gtype']=='JX' ? 'selected' : ''?>>江西时时彩</option>-->
                        <option value="TJ2"    <?=$_GET['gtype']=='TJ' || $_GET['gtype']=='TJ2' ? 'selected' : ''?>>天津时时彩</option>
                        <option value="GDSF2"  <?=$_GET['gtype']=='GDSF' || $_GET['gtype']=='GDSF2' ? 'selected' : ''?>>广东十分彩</option>
                        <option value="GXSF2"  <?=$_GET['gtype']=='GXSF' || $_GET['gtype']=='GXSF2' ? 'selected' : ''?>>广西十分彩</option>
                        <option value="TJSF2"  <?=$_GET['gtype']=='TJSF' || $_GET['gtype']=='TJSF2' ? 'selected' : ''?>>天津十分彩</option>
                        <option value="CQSF2"  <?=$_GET['gtype']=='CQSF'|| $_GET['gtype']=='CQSF2' ? 'selected' : ''?>>重庆十分彩</option> 
                        <option value="BJKN2"  <?=$_GET['gtype']=='BJKN' || $_GET['gtype']=='BJKN2' ? 'selected' : ''?>>北京快乐8</option> 
                        <option value="BJPK2"  <?=$_GET['gtype']=='BJPK' || $_GET['gtype']=='BJPK2' ? 'selected' : ''?>>北京PK拾</option>
                        <option value="GD112"  <?=$_GET['gtype']=='GD11' || $_GET['gtype']=='GD112' ? 'selected' : ''?>>广东11选5</option> 
                    </select>
                   <br /><br /> &nbsp;&nbsp;开奖期号：
                    <input name="qishu_query" type="text" id="qishu_query" value="<?=$qishu_query?>" size="20" maxlength="11"/>
					<br /><br />&nbsp;&nbsp;日期：
                    <select name="s_time" id="s_time">
                        <option value="<?=date("Y-m-d")?>"    <?=$_GET['s_time']==date("Y-m-d") ? 'selected' : ''?>><?=date('Y-m-d')?></option>
                        <option value="<?=date('Y-m-d',strtotime('-1 day'))?>"    <?=$_GET['s_time']==date('Y-m-d',strtotime('-1 day')) ? 'selected' : ''?>><?=date('Y-m-d',strtotime('-1 day'))?></option>
                        <option value="<?=date('Y-m-d',strtotime('-2 day'))?>"    <?=$_GET['s_time']==date('Y-m-d',strtotime('-2 day')) ? 'selected' : ''?>><?=date('Y-m-d',strtotime('-2 day'))?></option>
                        <option value="<?=date('Y-m-d',strtotime('-3 day'))?>"    <?=$_GET['s_time']==date('Y-m-d',strtotime('-3 day')) ? 'selected' : ''?>><?=date('Y-m-d',strtotime('-3 day'))?></option>
                        <option value="<?=date('Y-m-d',strtotime('-4 day'))?>"    <?=$_GET['s_time']==date('Y-m-d',strtotime('-4 day')) ? 'selected' : ''?>><?=date('Y-m-d',strtotime('-4 day'))?></option>
                        <option value="<?=date('Y-m-d',strtotime('-5 day'))?>"    <?=$_GET['s_time']==date('Y-m-d',strtotime('-5 day')) ? 'selected' : ''?>><?=date('Y-m-d',strtotime('-5 day'))?></option>
                        <option value="<?=date('Y-m-d',strtotime('-6 day'))?>"    <?=$_GET['s_time']==date('Y-m-d',strtotime('-6 day')) ? 'selected' : ''?>><?=date('Y-m-d',strtotime('-6 day'))?></option>
                    </select>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <input name="submit" type="submit" class="submit80" value="搜索"/>
                </td>
            </tr>
        </table>
    </form>
</div>
</div>
<div class="round-table">
    <table width="100%" border="0" cellpadding="5" cellspacing="1" class="font12" style="margin-top:2px;" bgcolor="#798EB9">
        <tr  class="title_tr" style="background-color:#2161b3; color:#FFF">
            <td align="center" width="16%"><strong>彩票类别</strong></td>
            <td align="center" width="16%"><strong>彩票期号</strong></td>
            <td align="center" width="20%"><strong>开奖时间</strong></td>
            <td align="center" width="16%"><strong>百位</strong></td>
            <td align="center" width="16%"><strong>十位</strong></td>
            <td align="center" width="16%"><strong>个位</strong></td>
        </tr>
        <?php


        $sql = "SELECT id,qishu,create_time,datetime,state,prev_text,
    ball_1,ball_2,ball_3
    FROM lottery_result_".$gType." WHERE DATE_FORMAT(datetime,'%Y-%m-%d') = '$query_time'";
        if($qishu_query){
            $sql .= " AND qishu = '$qishu_query'";
        }
        $sql .= " ORDER BY qishu DESC";
        $query	=	$mysqli->query($sql);
        $hasRow = "false";
		if($query)
        while($rows = $query->fetch_array()){
            $hasRow = "true";
            $color = "#FFFFFF";
            $over	 = "#EBEBEB";
            $out	 = "#ffffff";
            $hm 		= array();
            $hm[]		= BuLing($rows['ball_1']);
            $hm[]		= BuLing($rows['ball_2']);
            $hm[]		= BuLing($rows['ball_3']);
            ?>
            <tr   class="R_tr" align="center" onMouseOver="this.style.backgroundColor='<?=$over?>'" onMouseOut="this.style.backgroundColor='<?=$out?>'" style="background-color:<?=$color?>; line-height:20px;">
               <td height="25" align="center" valign="middle"><?=getZhPageTitle($lottery_type)?></td>
                <td align="center" valign="middle"><?=$rows['qishu']?></td>
                <td align="center" valign="middle"><?=$rows['datetime']?></td>
                <td align="center" valign="middle"><img src="/images/Lottery/Images/ball_2/<?=$rows['ball_1']?>.png"></td>
                <td align="center" valign="middle"><img src="/images/Lottery/Images/ball_2/<?=$rows['ball_2']?>.png"></td>
                <td align="center" valign="middle"><img src="/images/Lottery/Images/ball_2/<?=$rows['ball_3']?>.png"></td>
            </tr>
        <?php
        }
        if($hasRow=="false"){
            ?>
            <tr   class="R_tr" align="center" >
                <td height="25" colspan="10" align="center" valign="middle">暂时没有开奖结果</td>
            </tr>
        <?php
        }
        ?>
    </table>
</div>